package com.smartum.mpr.exception;

public enum ErrorCodes {
	NOT_VALID_CREDENTIONAL_ERROR(1, "Credientional is not valid"), TOKEN_NOT_VALID(2, "Token is not valid"), GENERATE_JSON_RESPONSE_ERROR(
	        3, "Internal server error"), INTERNAL_SERVER_ERROR(4, "Internal server error"), DATABASE_INTEGRITY_ERROR(5,
	        "Internal server error"), ALREADY_EXISTS_USER_ERROR(6, "User already exists"), NOT_VALID_PARAM(7,
	        "Internal server error"), ALREADY_LIKED(8, "Already liked"), INCORRECT_CREDENTIONALS(9,
	        "Incorrect credentionals"), NOT_EXISTS_IMAGE(10, "Not exists image"), NOT_EXISTS_ITEM(11, "Not exists item"), NOT_EXISTS_JOB(
	        12, "Not exists job"), NOT_EXISTS_USER(13, "Not exists user"), NOT_CORRECT_PERMISSION(14,
	        "not correct post permission"), NOT_EXISTS_CATEGORY(15, "not exists category"), NOT_EXISTS_SUBCATEGORY(16,
	        "not exists subcategory"), NOT_EXISTS_COUNTRY(17, "not exists country"), NOT_EXISTS_LIKE(18,
	        "not exists like"), NOT_EXISTS_NEWS(19, "not exists news"), NOT_SUPPORTED_IMAGE_FORMAT(20,
	        "unsupported image format"),ALREADY_SEXY(21, "Already sexy"),ALREADY_GANSTER(22, "Already gangster"),ALREADY_TYPED(23, "Already tiped"),
	        ALREADY_CLASSY(24, "Already classy"),ALREADY_ODD(25, "Already odd"),ALREADY_HOAX(26, "Already hoax");

	private String message;
	private int code;

	ErrorCodes(int code, String message) {
		this.message = message;
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public int getCode() {
		return code;
	}

	public static ErrorCodes getErrorCode(int code) {
		for (ErrorCodes ec : ErrorCodes.values()) {
			if (ec.getCode() == code) {
				return ec;
			}
		}
		return null;
	}

}
